package thread;

import java.util.concurrent.*;

public class demo19 {

    // 使用ThreadPoolExecutor创建一个忽略最新任务的线程池
    //1.核心线程数为5
    //2.最大线程数为10
    //3.任务队列为100
    //4.拒绝策略为忽略最新任务
    public static void main(String[] args) {
        ExecutorService service = new ThreadPoolExecutor(5, 10, 1, TimeUnit.HOURS,
                new ArrayBlockingQueue<Runnable>(100), new ThreadPoolExecutor.DiscardPolicy());

        for (int i = 0; i < 200; i++) {
            int id = i;
            service.submit(() -> {
                System.out.println("i = " + id);
            });
        }

    }
}
